#!/bin/bash

ip=$1
pass=$2

ip=${ip:=192.168.133.1}
pass=${pass:=root}

ssh-keygen -f "$HOME/.ssh/known_hosts" -R $ip

auto_login_ssh () {
expect -c "set timeout 5;
spawn ssh -o StrictHostKeyChecking=no $2 ${@:3};
expect assword:;
send -- $1\r;
interact;";
}

auto_login_ssh $pass root@$ip

